<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        /*
       备选字符集[海天]
        */
        var a="上海,上天,上去,上海那";
        var reg=/上[海天]/g;
        var b=a.replace(reg,"*");
        console.log(b);
        var c="123234dd";
        var d=/[0-9]/g;
        console.log(c.replace(d,"*"));
    </script>
</body>
</html>